一.使用图形化界面,创建vue项目
vue ui(在根目录下,打开cmd,启动图形化界面)
![](https://img-blog.csdnimg.cn/8c12549c4562418fbe4a482556e3df7e.png)
添加插件
![](https://img-blog.csdnimg.cn/196c3cc3625142d595f69b068f0fde3e.png)
添加element-ui插件
![](https://img-blog.csdnimg.cn/f6b57e90cab84a61a9123c3928d273b9.png)
这里选择import on demand
安装好了
![](https://img-blog.csdnimg.cn/aa6eeaf5b01d42e7a4f3bc50b88327a0.png)
添加依赖
添加axios依赖
添加好了
二.创建Git仓库,连接并上传刚刚创建的项目
![](https://img-blog.csdnimg.cn/69f6854b58994b16a934eba82b5c7a6b.png)
在项目文件目录下打开git的命令窗口,git bash here
查看状态git status,发现有很多文件没有加入暂存区,
然后将这些文件加入暂存区,git add .
与远程仓库建立连接,然后将项目推送到仓库
这样,创建的项目就与远程仓库建立连接并推送成功了
三.用idea打开刚刚的项目
![](https://img-blog.csdnimg.cn/f8653c9453114a00a060b3993f2f8d56.png)
在终端用命令创建一个login分支
创建分支之后,去启动项目
![](https://img-blog.csdnimg.cn/c553c35339094dcfa828783db484ad8a.png)
项目启动成功
![](https://img-blog.csdnimg.cn/449a25784ea644d4b35a8320268026b2.png)
如果很多文件颜色都是灰色的,那需要按照提示,安装所提示的东西
![](https://img-blog.csdnimg.cn/08d2f6f46bd54f0eb7438479194cf6d5.png)
修改
![](https://img-blog.csdnimg.cn/3637dc8a06b54bedbd4514126de94b63.png) ![](https://img-blog.csdnimg.cn/a6b2516fe592483bb0b5a738b68e71c2.png)
那么首页那些花花绿绿的就没有了,这个文件已修改,页面就会有效果
![](https://img-blog.csdnimg.cn/cb75786d9cee4b7987579624628bf00f.png)
然后去修改路由
一开始这样:
![](https://img-blog.csdnimg.cn/69e54584d914454097ba0a185b66bd19.png)
修改后:
![](https://img-blog.csdnimg.cn/04cdc23346df4ce98980047840c55242.png)
删掉组件下面自带的文件,新建一个Login.vue文件,我们登录页面的内容就写在这个文件里面
![](https://img-blog.csdnimg.cn/26311751c3694966ab2e042d6b6658a7.png)
login.vue文件建好之后,我们要在index.js文件当中,配置好login.vue的路 由
![](https://img-blog.csdnimg.cn/9e63bfcce6ab4ebf8eaad5241d08a0f7.png)
![](https://img-blog.csdnimg.cn/fb2f1a4a2c2042428445f86cdff0e82b.png)
不要忘了App.vue里面还有个路由显示出口,出口你都不写,页面怎么显示效果
![](https://img-blog.csdnimg.cn/38f79bc34490404088938d9b37ee9169.png)
然后我们现在就开始在Login.vue这个文件里面写我们需要的内容
首先我们去设置全局的css样式
![](https://img-blog.csdnimg.cn/9e05bd7fa9504f3b85d06116e5836fdf.png)
然后将他引入到main.js这个文件中
这个文件就是你后续需要用到什么依赖啊啥的,就要引入到这个文件中
![](https://img-blog.csdnimg.cn/909a5c6c067042d4b2a62a4cc3bca809.png)
less有什么用
![](https://img-blog.csdnimg.cn/88c2adfb942044d383dfc3ef273b184c.png)
less报错,是因为缺少依赖,那么要去安装两个依赖
![](https://img-blog.csdnimg.cn/f4d816ca1d404d81b24bcba4ebe86ebc.png)
![](https://img-blog.csdnimg.cn/6964ba716e494171a148bbc8a0ad6ce6.png)
![](https://img-blog.csdnimg.cn/a79e23ff0f534d3ab99406f7d9212c74.png)
![](https://img-blog.csdnimg.cn/edb82f6112314377b63a9dbc2e37128b.png)
然后页面就显示了
![](https://img-blog.csdnimg.cn/eabe59bf0a4e496a8cc25395e0c3539e.png)
在assets这个包下面建一个css目录,再建一个
最终登录的界面效果
![](https://img-blog.csdnimg.cn/8b61118ce4074f159f4301338f222df1.png)
{msg}}-->
登录
取消
export default {
// eslint-disable-next-line vue/multi-word-component-names
name: 'Login',
data: function () {
return {
msg: 'zsf'
}
}
}
.login_container {
//background-color: #d4edda;
background-color: powderblue;
background-image: linear-gradient(to right,powderblue,deepskyblue);
height: 100%;
}
.login_box{
width: 450px;
height: 450px;
//background-color: antiquewhite;
background-color: white;
border-radius: 15%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
box-shadow: 0 0 10px powderblue;/*加阴影*/
.tp_box{
position: fixed;
left: 50%;
transform: translate(-50%);
border-radius: 50%;/*圆角*/
background-color:powderblue;
width: 120px;
height: 120px;
padding: 10px;
box-shadow: 0 5px 20px deepskyblue;/*加阴影*/
img{
width: 100%;
height: 100%;
border-radius: 50%;
}
}
}
.btns{
display: flex;
justify-content: flex-end;
}
.login_form{
position: absolute;
left: 50%;
transform: translate(-50%);
bottom: 60px;
width: 90%;
padding: 0px 20px;
/*就算你要撑起来,你也只能往里面撑起来*/
box-sizing: border-box;
}
另一个样式
![](https://img-blog.csdnimg.cn/e6740123cc784741bf4fc556d4d3f193.png)
![](https://img-blog.csdnimg.cn/cbb9292e11e642698eb1605dee63e8b6.png)
加上表单验证并实现重置
![](https://img-blog.csdnimg.cn/5e327556b2504430b73bfce4971b5291.png)
![](https://img-blog.csdnimg.cn/fbd49c6273db4b879b92f6093d5ba242.png)
{msg}}-->
登录
取消
export default {
// eslint-disable-next-line vue/multi-word-component-names
name: 'Login',
data () {
return {
loginForm: {
username: '',
password: ''
},
loginFormRules: {
username: [
/* blur:失去焦点的时候触发 */
{
required: true,
message: '请输入用户名',
trigger: 'blur'
},
{
min: 6,
max: 9,
message: '长度在 6 到 9 个字符',
trigger: 'blur'
}
],
password: [
/* blur:失去焦点的时候触发 */
{
required: true,
message: '请输入密码',
trigger: 'blur'
},
{
min: 6,
max: 9,
message: '长度在 6 到 9 个字符',
trigger: 'blur'
}
]
}
}
},
methods: {
resetLoginForm () {
console.log(this)
this.$refs.loginFormRef.resetFields()
}
}
}
.login_container {
//background-color: #d4edda;
background-color: powderblue;
//background-image: linear-gradient(to right,powderblue,deepskyblue);
background-image: linear-gradient(to right, powderblue, pink, plum);
height: 100%;
}
.login_box {
width: 450px;
height: 450px;
//background-color: antiquewhite;
background-color: white;
border-radius: 15%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
box-shadow: 0 0 10px powderblue; /*加阴影*/
.tp_box {
position: fixed;
left: 50%;
transform: translate(-50%);
border-radius: 50%; /*圆角*/
background-color: powderblue;
width: 120px;
height: 120px;
padding: 10px;
box-shadow: 0 5px 20px deepskyblue; /*加阴影*/
img {
width: 100%;
height: 100%;
border-radius: 50%;
}
}
}
.btns {
display: flex;
justify-content: flex-end;
}
.login_form {
position: absolute;
left: 50%;
transform: translate(-50%);
bottom: 60px;
width: 90%;
padding: 0px 20px;
/*就算你要撑起来,你也只能往里面撑起来*/
box-sizing: border-box;
}
再用一下阿里巴巴的图标库
https://www.iconfont.cn/ 小俊会编码:..123123
![](https://img-blog.csdnimg.cn/ff030774f66d46a4832a7fecc913b851.png)
下载好之后,将压缩包解压,将文件夹加入到项目assets目录下
![](https://img-blog.csdnimg.cn/61ef26213f6d442a8d9838f7c0f00337.png)
在表单输入框当中使用
![](https://img-blog.csdnimg.cn/fd37e08bec564a7d93852dae70093cca.png)
![](https://img-blog.csdnimg.cn/7fd9a85361e44da8896087f38039e76f.png)
转载自CSDN-专业IT技术社区
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/qq_60555957/article/details/127100669
|